package com.fanshuai2.niuke.strings;
import java.util.*;

public class Filename {
    static class Record {
        String filename;
        String line;
        int count;

        public Record(String line) {
            int startIndex = line.lastIndexOf("\\");
            if (startIndex >= 0) {
                line = line.substring(startIndex + 1);
            }

            String[] arr = line.split(" ");
            filename = arr[0];
            if (filename.length() > 16) {
                int index = filename.length() - 16;
                filename = filename.substring(index);
            }

            this.filename = filename;
            this.line = arr[1];
        }

        public boolean equals(Object o) {
            if (this == o) {
                return true;
            }
            if (null == o) {
                return false;
            }
            if (!(o instanceof Record)) {
                return false;
            }
            Record r = (Record) o;
            return r.filename.equals(filename) && r.line.equals(line);
        }

        public int hashCode() {
            return Objects.hash(filename, line);
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        LinkedHashMap<Record, Integer> map = new LinkedHashMap<>();
        while (in.hasNextLine()) {
            String line = in.nextLine();
            Record r = new Record(line);

            Integer count = map.get(r);
            count = null == count ? 1 : count + 1;
            map.put(r, count);
        }

        List<Record> list = new ArrayList<>();
        for (Record r : map.keySet()) {
            int count = map.get(r);
            r.count = count;
            list.add(r);
        }

        int index = 0;
        if (list.size() > 8) {
            index = list.size() - 8;
        }
        for (int i = index; i < list.size(); i++) {
            Record r = list.get(i);
            String s = r.filename + " " + r.line + " " + r.count;
            System.out.println(s);
        }

    }
}
